/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Projet;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.ArrayList;
import java.util.Scanner;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author DESGROUAS Romain L3INFO
 */
public class Main {

	/**
	 * @param args the command line arguments
	 */
	public static void main(String[] args) {
		try {
			ChercherMin cm = new ChercherMin();
			Lecture l = new Lecture();

			System.out.println("Projet Algorithmique et Structures de donnees 3");
			System.out.println("               DESGROUAS Romain                ");

			if (args.length == 0) {
				System.out.println("Il faut donner un nom de fichier en argument");
				System.out.println("Fin du programme");
				System.exit(1);
			}
			Scanner sc = new Scanner(new FileReader(args[0]));


			int[] permut;
			ArrayList<Paire> C;

			while (sc.hasNextLine()) {

				permut = l.Permutation(sc);

				System.out.print("\nTraitement de la permutation : (");
				for (int i = 1; i < permut.length; i++) {
					System.out.print(permut[i]);
					if (i != permut.length - 1) {
						System.out.print(", ");
					}
				}
				System.out.println(")");
				cm.ChercheMinPremier(permut);
				sc.nextLine();

//				/**************************************************************/
//				/*************************TESTS UNION-FIND*********************/
//				/**************************************************************/
//				
//				int pp;
//				UnionFind uf = new UnionFind(permut.length);
//				System.out.println("\nCreation de la structure Union-Find");
//				System.out.println(uf);
//
//				pp=uf.UnionParRang(1, 2);
//				System.out.println("union(1, 2) :");
//				System.out.println(uf);
//
//				pp=uf.UnionParRang(3, 4);
//				System.out.println("union(3, 4) :");
//				System.out.println(uf);
//
//				pp=uf.UnionParRang(1, 5);
//				System.out.println("union(1, 5) :");
//				System.out.println(uf);
//
//				pp=uf.UnionParRang(6, 7);
//				System.out.println("union(6, 7) :");
//				System.out.println(uf);
//				
//				pp=uf.UnionParRang(1, 6);
//				System.out.println("union(1, 6) :");
//				System.out.println(uf);
//
//				pp=uf.UnionParRang(3, 1);
//				System.out.println("union(3, 1) :");
//				System.out.println(uf);
//				
//				System.out.println("find(7) : " + uf.Find(7));
//				System.out.println("find(0) : " + uf.Find(0));
			}

		} catch (FileNotFoundException ex) {
			Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
		}

	}
}
